package com.esri.core.map;

import com.esri.core.internal.util.d;
import java.io.IOException;
import java.io.StringWriter;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;

/* loaded from: classes.dex */
public class LayerInfo implements LayerInfoItem {
    private int a;
    private LayerSource b;
    private String c;

    public LayerInfo(int i, LayerSource layerSource) {
        this.a = -1;
        this.a = i;
        this.b = layerSource;
    }

    @Override // com.esri.core.map.LayerInfoItem
    public int getId() {
        return this.a;
    }

    @Override // com.esri.core.map.LayerInfoItem
    public void setId(int i) {
        this.a = i;
    }

    public LayerSource getLayerSource() {
        return this.b;
    }

    public void setLayerSource(LayerSource layerSource) {
        this.b = layerSource;
    }

    public String getDefinitionExpression() {
        return this.c;
    }

    public void setDefinitionExpression(String str) {
        this.c = str;
    }

    @Override // com.esri.core.map.LayerInfoItem
    public String toJson() throws Exception {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator a = d.a(stringWriter);
        a.writeStartObject();
        toJson(a);
        a.writeEndObject();
        a.close();
        return stringWriter.toString();
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public void toJson(JsonGenerator jsonGenerator) throws IOException, JsonGenerationException, Exception {
        jsonGenerator.writeNumberField("id", this.a);
        jsonGenerator.writeFieldName("source");
        jsonGenerator.writeRawValue(this.b.toJson());
        String str = this.c;
        if (str == null || str.length() <= 0) {
            return;
        }
        jsonGenerator.writeStringField("definitionExpression", this.c);
    }
}
